package com.caiheng.api.service.estate.impl;

import com.caiheng.api.dao.estate.RepairRecordImgMapper;
import com.caiheng.api.entity.estate.RepairRecordImg;
import com.caiheng.api.service.estate.RepairRecordImgService;
import com.caiheng.api.service.base.impl.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class RepairRecordImgServiceImpl extends BaseServiceImpl<RepairRecordImgMapper, RepairRecordImg> implements RepairRecordImgService {
    @Resource
    private RepairRecordImgMapper repairRecordImgMapper;
    @Value("${web.imgPrefix}")
    private String imgPrefix;//图片地址


    @Override
    public List<RepairRecordImg> getListByRecordId(int recordId) {
        List<RepairRecordImg> imgs = repairRecordImgMapper.selectListByColumn("record_id",recordId);
        if(imgs!=null && imgs.size() > 0){
            for(RepairRecordImg img : imgs){
                if(img!=null){
                    String img_key = img.getImgUrl()!=null ? img.getImgUrl() : "";
                    if(!img_key.equals("")){
                        img.setImgUrl(imgPrefix + img_key);
                    }
                }
            }
        }
        return imgs;
    }
}
